package jdk.thread.tool;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;


/**
 * CountDownLatch和CyclicBarrier大体相同，
 * 不同的是CountDownLatch可以只等待而不减计数（因为两者都是计数为零时开放执行）分为两个操作await和countDown, 而CyclicBarrier只有一个操作await（等减一体)
 */
public class CountDownLatchTest {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(10);

        latch.countDown();
        latch.countDown();
        latch.await();
        latch.await(1000, TimeUnit.MILLISECONDS);
    }

}
